package jetpack.com.pzl.works;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.work.Data;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

public class Worker1 extends Worker {
    final String TAG = "jinx_Worker1";

    public Worker1(@NonNull Context context, @NonNull WorkerParameters workerParams) {
        super(context, workerParams);
    }

    @NonNull
    @Override
    public Result doWork() {
        Log.i(TAG, "Worker1   start : " + Thread.currentThread().getName());
        int i = 0;
        while (i <= 10) {

            Log.i(TAG, "Worker1    执行  ..." + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i++;
        }
        Log.i(TAG, "Worker1   : " + Thread.currentThread().getName() + " 完成");

        Data.Builder builder = new Data.Builder();
        builder.putString("result1", "worker1 结果：《像风一样》");
        return Result.success(builder.build());
    }

}
